﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NRCP.Helpers;
using NRCP.BusinessLogicLayer;
using NRCP.BusinessEntities;

namespace NRCP
{
    public class NationalPlanBase : System.Web.UI.Page
    {
        internal NationalPlanSteps PresentPageStep
        {
            get;
            set;
        }

        internal void CheckSteps()
        {
            if (!string.IsNullOrEmpty(SiteUtility.QueryParam))
            {
                NationalPlanBLL nationalPlanBll = new NationalPlanBLL();
                NationalPlan plan = nationalPlanBll.GetNationalPlanById(SiteUtility.IntQueryParam);
                if (plan.CompletedSteps == CompletedSteps.Complete.ToString() && PresentPageStep != NationalPlanSteps.Complete)
                {
                    HttpContext.Current.Response.Redirect(SiteSettings.BaseUrl + "Complete.aspx?params=" + SiteUtility.QueryParam, true);
                }
                else if (plan.CompletedSteps == CompletedSteps.MonthlyPlan.ToString() && PresentPageStep != NationalPlanSteps.Complete)
                {
                    HttpContext.Current.Response.Redirect(SiteSettings.BaseUrl + "Complete.aspx?params=" + SiteUtility.QueryParam, true);
                }
                else if (plan.CompletedSteps == CompletedSteps.YearlyPlan.ToString() && PresentPageStep != NationalPlanSteps.MonthlyPlan)
                {
                    HttpContext.Current.Response.Redirect(SiteSettings.BaseUrl + "zonal-plan.aspx?params=" + SiteUtility.QueryParam, true);
                }
                else if (plan.CompletedSteps == CompletedSteps.Configure.ToString() && PresentPageStep != NationalPlanSteps.YearlyPlan)
                {
                    HttpContext.Current.Response.Redirect(SiteSettings.BaseUrl + "national-plan.aspx?params=" + SiteUtility.QueryParam, true);
                }
                else
                {
                }
            }
        }
     
    }
}